package com.sinosoft.ptas.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import com.sinosoft.framework.core.common.exception.BusinessException;
import com.sinosoft.ptas.dao.AuditEntityMapper;
import com.sinosoft.ptas.entity.AuditEntity;
import com.sinosoft.ptas.service.AuditService;
import com.sinosoft.ptas.system.commom.ExceptionConstant;

@Service
@Validated
public class AuditServiceImpl implements AuditService {
	
	AuditEntityMapper auditMapper;

	public void setAuditMapper(AuditEntityMapper auditMapper) {
		this.auditMapper = auditMapper;
	}

	/**
	 * 增加
	 * @param id
	 * @return
	 */
	public String createAudit( AuditEntity auditEntity) throws BusinessException{
		
		if(auditEntity==null){
			throw new  BusinessException(ExceptionConstant.DATA_NULL_MESSAGE);
		}
		String id=UUID.randomUUID().toString();
		auditEntity.setId(id);
		auditMapper.createAudit(auditEntity);
		return id;
	}

	/**
	 * 通过id删除（进行审核表的删除，单独删除）
	 * @param id
	 * @return
	 */
	public void deleteAudit(String id) {
		 auditMapper.deleteAudit(id);
	}


	/**
	 * 更新 审核表
	 * @param auditEntity
	 * @return
	 */
	public void updateAudit( AuditEntity auditEntity) throws BusinessException{
		 auditMapper.updateAudit(auditEntity);
	}
	
	/**
	 * 查询全部
	 * @return
	 */
	public List<AuditEntity> retrieveAudit(AuditEntity auditEntity) {
		return auditMapper.retrieveAudit(auditEntity);
	}

	/**
	 * 根据id查询
	 * @param id
	 * @return
	 */
	public AuditEntity retrieveAuditById(String id) {
		return auditMapper.retrieveAuditById(id);
	}

	/**
	 * 根据申报表中的id查出该申报表对应的某一条审核表信息
	 * @param reportId
	 * @return
	 */
	public AuditEntity retrieveAuditByReportId(String reportId) {
		return auditMapper.retrieveAuditByReportId(reportId);
	}

	

}
